package com.shsnc.agent;

import net.bytebuddy.agent.builder.AgentBuilder;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.dynamic.DynamicType;
import net.bytebuddy.implementation.MethodDelegation;
import net.bytebuddy.matcher.ElementMatchers;
import net.bytebuddy.utility.JavaModule;

/**
 *
 * @author zll
 * @date 2021/8/5
 *
 * 声明增强操作
 */
public class LogAddTransformer implements AgentBuilder.Transformer {
	@Override
	public DynamicType.Builder<?> transform(DynamicType.Builder<?> builder, TypeDescription typeDescription, ClassLoader classLoader, JavaModule javaModule) {
		//对add方法添加拦截
		return builder.method(ElementMatchers.named("add"))
				.intercept(MethodDelegation.to(LogIntercept.class));
	}
}
